<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>iframe跨域通信-child-dom</title>

</head>
<body>
  <h2>iframe跨域通信-child-dom  </h2>
</body>
</html>

<script>

function handleMessage (event) {
      // 根据上面制定的结构来解析 iframe 内部发回来的数据

      console.log('iframe跨域通信 child dom handleMessage : ' , event.data );


    window.parent.postMessage( '来自 iframe child 节点： '+ JSON.stringify(event.data) , '*')

    if(event && event.data && event.data.certificate ){
      window.parent.postMessage( {verify:true} , '*')
    }


}


    window.addEventListener('message', handleMessage)

    window.parent.postMessage('this is child dom , ready ... ', '*')


</script>